using System;
using System.Collections.Generic;
using System.Text;
using log4net;
using log4net.Config;
using System.IO;

namespace WhsFacebook.Whs.Logging
{
    public sealed class LogFactory
    {
        public static void Configure(string logName)
        {
            if (string.IsNullOrEmpty(logName))
                throw new ArgumentException("null or empty", "logName");

            var fi = new FileInfo(string.Format(
                Properties.Constants.Log4NetConfigPath,
                logName
                ));

            if (!fi.Exists)
                throw new FileNotFoundException(fi.FullName);

            // configure
            XmlConfigurator.Configure(fi);

            // initialize
            var log = log4net.LogManager.GetLogger(typeof (LogFactory));

            log.Info("-------------------------------------------------------------- WHS on FACEBOOK --------------------------------------------------------------");

            log.Info("Instance ID: " + WhsFacebookRegistry.GetInstanceId());

            log.Info("Windows Home Server version: " + System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetEntryAssembly().Location).FileVersion);

            // log header
            WhsFacebookVersion.LogVersion();
        }
    }
}
